package routers

import (
	"gitee.com/huerbiao/robot/middleware/logging"
	"github.com/gin-contrib/gzip"
	"github.com/gin-gonic/gin"
	"net/http"
)

func SetupRouter() *gin.Engine {
	//r := gin.Default()
	r := gin.New()
	r.Use(logging.RegisterLog())
	r.Use(gin.RecoveryWithWriter(logging.WriterLevel("error")))
	r.Use(logging.Recovery(logging.RecoveryHandler))
	//g.Use(author.CheckSign())
	r.Use(gzip.Gzip(gzip.DefaultCompression))
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": "pong",
		})
	})
	//机器人服务
	RobotService(r)
	return r
}
